package com.yixuan.mt.common.mapper;

import com.yixuan.mt.common.entity.Bucket;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BucketsMapper {

    @Insert("insert into buckets (name, access_policy, created_time) values (#{name}, #{accessPolicy}, #{createdTime})")
    void insertBucket(Bucket bucket);

    @Delete("delete from buckets where name = #{bucketName} and object_num = 0")
    int deleteBucket(String bucketName);

    void updateBuckets(Bucket bucket);

    @Select("select * from buckets")
    List<Bucket> getBuckets();

    @Select("select object_num from buckets where name = #{bucketName}")
    Integer selectObjectNum(String bucketName);

    @Select("select access_policy from buckets where name = #{bucketName}")
    Bucket selectBucketsSummary(String bucketName);
}
